/*
 * Copyright (C) 2018 wxyz <hyhjwzx@126.com>
 * This program can be distributed under the terms of the GNU GPL Version 2.
 * See the file LICENSE.
 *
 */

package ren.wxyz.study.euler.hp01;

import ren.wxyz.study.euler.base.IProblem;
import ren.wxyz.study.euler.util.ConsoleHelper;
import ren.wxyz.study.euler.util.MathHelper;

/**
 * 第 10 题
 *
 * @auther wxyz 2018-04-21_13:56
 * @since 1.0
 */
public class P010 implements IProblem {

    @Override
    public void main(String[] args) throws Throwable {
        if (args.length < 1) {
            ConsoleHelper.error("至少包含一个指定的大小。");
            return;
        }
        long limitNumber = Long.parseLong(args[0]);

        long sum = 0L;
        for (long i = 2; i < limitNumber; i++) {
            if (MathHelper.isPrimeNumber(i)) {
                sum += i;
            }
        }

        ConsoleHelper.printf("所有小于 %1$d 的素数的和是 %2$d \r\n", limitNumber, sum);
    }
}
